import 'package:flutter/material.dart';
import 'package:ref/ref.dart';
import 'package:ref_example/test_list/test_list.dart';
import 'package:ref_example/test_map/test_map.dart';
import 'test_base/test_base.dart';
import 'test_class/test_class.dart';
import 'test_compute/test_compute.dart';
import 'test_key/test_key.dart';
import 'test_keys/test_keys.dart';
import 'test_updae/test_update.dart';
import 'test_watch/test_watch.dart';

class Mvvm extends StatefulWidget {
  const Mvvm({Key? key}) : super(key: key);

  @override
  _MvvmState createState() => _MvvmState();
}

class _MvvmState extends State<Mvvm> {
  Ref<int> myAge = Ref(12);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Test Mvvm page'),
      ),
      body: ListView(children: [
        Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Container(
              height: 50,
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  RefBuilder(() => Text(myAge.value.toString())),
                  TextButton(
                      onPressed: () {
                        myAge.value++;
                      },
                      child: Text('+ 1')),
                ],
              ),
            ),
            Wrap(
              children: [
                TestBase(),
                TestClass(),
                TestMap(),
                TestList(),
                TestWatch(),
                TestCompute(),
                TestKey(),
                TestKeys(),
                TestUpdate(),
                // TestStream(),
              ],
            ),
            SizedBox(height: 50)
          ],
        ),
      ]),
    );
  }
}
